/*
  ID: nemokin1
  PROG: ariprog
  LANG: C++
  using: truncate dfs, seems use too much time
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
 
using namespace std;
 
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=b;--i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define ALL(c) (c).begin(),(c).end()
 
#define debug(x) cerr<< #x << " = " << (x) << "\n";
#define debugv(v) cerr << #v << " = "; FOREACH(it,v) cerr << *it <<","; cerr << "\n";
#define SIZE(a)  (int(a.size()))
 
template<typename T> inline void checkMax(T& a, T b) {if (b>a) a=b;}
template<typename T> inline void checkMin(T& a, T b) {if (b<a) a=b;}
 
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef long double ld;
const int INF = 1000000000;

int main() {
    freopen("ariprog.in","r",stdin);
    freopen("ariprog.out","w",stdout);
    int M;
    int N;
    vector<pair<int,int> > ret;
    
    cin >> N >> M;
    bitset<125001> b;
    vector<int> v;
    
    for(int i = 0; i <= M; i++){
	for(int j = i; j <= M; j++){
	    b.set(i*i+j*j);
	}
    }
    
    for(int i = 0; i < 125001; i++)
	if(b[i] == 1) v.push_back(i);
    
    for(int i = 0; i < v.size(); i++){
    	for(int j = i+1; j < v.size(); j++){
    	    bool test = true;
    	    int start = v[j];
    	    int addon = v[j] - v[i];
    	    int tt;
    	    for(tt = 0; tt < N-2; tt++){
    		start+=addon;
		if(start >= 125001){
		    test = false;
		    break;
		}
    		if(b[start] == 0) {test = false;break;}
    	    }
    	    if(test){
    		ret.push_back(make_pair(addon,v[i]));
    	    }
    	}
    }
    sort(ALL(ret));
    if(ret.size() == 0) cout<<"NONE"<<endl;
    for(int i = 0; i < ret.size(); i++)
    	cout<<ret[i].second<<" "<<ret[i].first<<endl;
    exit(0);
}
    
